//
//  CJExtralItemCollectionViewDataSource.h
//  CJUIKitDemo
//
//  Created by ciyouzen on 2016/11/12.
//  Copyright © 2016年 dvlproad. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "CJDataSourceSettingModel.h"
#import "CJTagSectionDataModel.h"


NS_ASSUME_NONNULL_BEGIN

/**
 *  tableView只有一种Cell，且tableView不分区时候的dataSoure
 */
@interface CJExtralItemCollectionViewDataSource : NSObject <UICollectionViewDataSource> {
    
}
@property (nonatomic, copy, readonly) CJDataSourceSettingModel* (^ _Nullable sectionSettingBlock)(NSInteger section);

@property (nonatomic, strong) NSMutableArray<CJTagSectionDataModel *> *sectionModels;

/*
 *  初始化dataSource类(初始化完之后，必须在之后设置想要展示的数据dataModels)
 *
 *  @param sectionSettingBlock                  集合视图的每个section的设置（当某个section的这个block①为nil时,该区个数无限制且无额外item,即显示实际个数；②为非nil时,该区个数可限制且可设置个数未超限时,额外item的位置(当有个数限制且超过后，+号会隐藏)）
 *  @param cellForItemAtIndexPathBlock          dataSource中的cell(含dataCell和extralCell)进行定制用的block
 */
- (id)initWithSectionSettingBlock:(CJDataSourceSettingModel* (^ _Nullable)(NSInteger section))sectionSettingBlock
      cellForItemAtIndexPathBlock:(UICollectionViewCell* (^)(UICollectionView *collectionView, NSIndexPath *indexPath, BOOL isExtralItem))cellForItemAtIndexPathBlock NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;



#pragma mark - Update
/*
 *  更新section的设置
 *
 *  @param sectionSettingBlock                  集合视图的每个section的设置(可为nil，为nil表示无个数限制，且无额外item)
 */
- (void)updateSectionSettingBlock:(CJDataSourceSettingModel* (^ _Nullable)(NSInteger section))sectionSettingBlock;

/*
 *  dataSoure中indexPath位置的dataModel值
 *
 *  @param indexPath collectionView的indexPath
 *
 *  @return dataModel(indexPath为nil,返回nil，常见于查看当前选中的dataModel)
 */
- (id)dataModelAtIndexPath:(nullable NSIndexPath *)indexPath;

/*
*  判断indexPath是否是非数据即额外加上去的cell（如添加图片的cell）
*
*  @param indexPath     要判断的indexPath
*
*  @return indexPath    是否是非数据即额外加上去的cell（如添加图片的cell）
*/
- (BOOL)isExtraItemIndexPath:(NSIndexPath *)indexPath;

@end

NS_ASSUME_NONNULL_END
